package com.robot.orders.controller;

import com.alibaba.fastjson.JSON;
import com.robot.orders.pojo.Settlement;
import com.robot.orders.service.SettlementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * settlement控制器层
 *
 * @author wuyunbin
 */
@RestController
@CrossOrigin
@RequestMapping("/settlement")
public class SettlementJsonController {
    @Autowired
    private SettlementService settlementService;

    /**
     * 增加结算总表
     *
     * @param settlement
     * @return
     */
    @PostMapping(value = "third/addSettlement", produces = "application/json; charset=utf-8")
    public void thirdAddSettlement(@RequestBody String settlement) {
        settlementService.add(JSON.parseObject(settlement, Settlement.class));
    }

    /**
     * 更改settlement表的status状态,0-未提现 1-已提现
     *
     * @param status
     * @param agentId
     * @param settlementDate
     */
    @PutMapping(value = "third/updateSettlementStatus/{status}/{agentId}/{settlementDate}", produces = "application/json; charset=utf-8")
    public void thirdUpdateSettlementStatus(@PathVariable String status, @PathVariable String agentId, @PathVariable String settlementDate) {
        settlementService.updateSettlementStatus(status, agentId, settlementDate);
    }
}
